package Tests;

import junit.framework.Assert;

import org.junit.Test;

import Core.*;

public class CharacterImplTests
{
	@Test
	public void manaTest()
	{
		CharacterImpl character = new CharacterImpl(null);

		character.setMaxMana(1000);
		character.setCurrentMana(1000);
		character.subtractMana(500);
		
		Assert.assertEquals(500, character.getCurrentMana(), .01);
	}

	@Test
	public void settingCurrentManaAboveMaxWillCorrectToMax()
	{
		CharacterImpl character = new CharacterImpl(null);
		
		character.setMaxMana(100);
		character.setCurrentMana(150);
		
		Assert.assertEquals(100.0, character.getCurrentMana(), .1);
	}
	
	@Test
	public void actionPointTest() {
		CharacterImpl character = new CharacterImpl(null);
		
		character.setMaxActionPoints(10);
		character.setCurrentActionPoints(10);
		character.subtractActionPoints(6);
	
		Assert.assertEquals(4.0, character.getCurrentActionPoints(), .1);
	}
	
	@Test
	public void settingActionPointsAboveMaxActionPointsCorrectsToMax()
	{
		CharacterImpl character = new CharacterImpl(null);
		
		character.setMaxActionPoints(10);
		character.setCurrentActionPoints(15);
		
		Assert.assertEquals(10.0, character.getCurrentActionPoints(), .1);
	}
	
	@Test
	public void maxManaTest()
	{
		CharacterImpl character = new CharacterImpl(null);
		double delta = .1;
		
		Assert.assertEquals(0.0, character.getMaxMana(), delta);
		
		character.setMaxMana(100);
		
		Assert.assertEquals(100.0, character.getMaxMana(), delta);
		
		character.increaseMaxMana(50);
		
		Assert.assertEquals(150.0, character.getMaxMana(), delta);
	}
	
	@Test
	public void maxActionPointTest()
	{
		CharacterImpl character = new CharacterImpl(null);
		
		Assert.assertEquals(0.0, character.getMaxActionPoints(), .1);
		
		character.setMaxActionPoints(10);
		
		Assert.assertEquals(10.0, character.getMaxActionPoints(), .1);
	}
	
	@Test
	public void currentHitPointTest()
	{
		CharacterImpl character = new CharacterImpl(null);

		character.setMaxHitPoints(100);
		character.setCurrentHitPoints(100);
		
		Assert.assertEquals(100.0, character.getCurrentHitPoints(), .1);
	}
	
	@Test
	public void hitPointMaxTest()
	{
		double delta = .1;
		CharacterImpl character = new CharacterImpl(null);
		
		Assert.assertEquals(0.0, character.getMaxHitPoints(), delta);
		
		character.setMaxHitPoints(50.0);
		
		Assert.assertEquals(50.0, character.getMaxHitPoints(), delta);
		
		character.increaseMaxHitPoints(100.0);
		
		Assert.assertEquals(150.0, character.getMaxHitPoints(), delta);
	}
	
	@Test
	public void settingCurrentHitPointsAboveMaxAutoCorrects()
	{
		CharacterImpl character = new CharacterImpl(null);
		
		character.setMaxHitPoints(100.0);
		character.setCurrentHitPoints(150.0);
		
		Assert.assertEquals(100.0, character.getCurrentHitPoints(), 0.1);
	}
}
